//
//  Header.h
//  iOSCodeLearning
//
//  Created by TFAppleWork-Summer on 2017/12/12.
//  Copyright © 2017年 Ace. All rights reserved.
//

#ifndef Header_h
#define Header_h

// .h 文件 暴露一个创建单例的宏
#define SingleH(name) + (instancetype)share##name;

// 在宏里面想要换行 在一行的最后 加上"\"
#define SingleM(name)  static id _instance;\
+ (instancetype)allocWithZone:(struct _NSZone *)zone{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
    if (_instance == nil) {\
        _instance = [super allocWithZone:zone];\
    }\
});\
return _instance ;\
}\
+ (instancetype)share##name{\
    return [[self alloc] init];\
}\
- (id)copyWithZone:(NSZone *)zone{\
return _instance;\
}\
- (id)mutableCopyWithZone{\
    return _instance;\
}

#endif /* Header_h */
